package com.itheima.demoString;

import java.util.Scanner;

//定义一个方法,完成字符串的反转
public class Demo09String {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串:");
        String s = sc.next();
        String str = reverse(s);
        System.out.println("反转后的字符串为: " + str);
    }

    public static String reverse(String str) {
        String result = "";
        for (int index = str.length() - 1; index >= 0; index--) {
            result+= str.charAt(index);
        }
        return result;
    }
}
